<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>Hugo博客写作指南 - Pour l&#39;honneur de l&#39;esprit humain.</title><meta name="Description" content=""><meta property="og:title" content="Hugo博客写作指南" />
<meta property="og:description" content="自从博客从 Hexo 迁移到 Hugo 之后，购买了个人域名 xiaofy.top ，基本上也是经常更新，也逐渐形成了个人博客更新写作的整个工具链。 如果是本地只写作博客的话，我使用 Typora" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://feiyuxiaoThu.github.io/posts/hugo%E5%8D%9A%E5%AE%A2%E5%86%99%E4%BD%9C%E6%8C%87%E5%8D%97/" /><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2020-07-01T09:11:25+08:00" />
<meta property="article:modified_time" content="2020-07-01T09:11:25+08:00" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Hugo博客写作指南"/>
<meta name="twitter:description" content="自从博客从 Hexo 迁移到 Hugo 之后，购买了个人域名 xiaofy.top ，基本上也是经常更新，也逐渐形成了个人博客更新写作的整个工具链。 如果是本地只写作博客的话，我使用 Typora"/>
<meta name="application-name" content="LoveIt">
<meta name="apple-mobile-web-app-title" content="LoveIt"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="http://feiyuxiaoThu.github.io/posts/hugo%E5%8D%9A%E5%AE%A2%E5%86%99%E4%BD%9C%E6%8C%87%E5%8D%97/" /><link rel="prev" href="http://feiyuxiaoThu.github.io/posts/%E8%B0%88%E8%B0%88kmt%E5%92%8C%E4%B9%9D%E4%BA%8C%E5%85%B1%E8%AF%86/" /><link rel="next" href="http://feiyuxiaoThu.github.io/posts/%E7%A7%8B%E6%8B%9B%E6%80%BB%E7%BB%93/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Hugo博客写作指南",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "http:\/\/feiyuxiaoThu.github.io\/posts\/hugo%E5%8D%9A%E5%AE%A2%E5%86%99%E4%BD%9C%E6%8C%87%E5%8D%97\/"
        },"genre": "posts","keywords": "hugo, markdown","wordcount":  358 ,
        "url": "http:\/\/feiyuxiaoThu.github.io\/posts\/hugo%E5%8D%9A%E5%AE%A2%E5%86%99%E4%BD%9C%E6%8C%87%E5%8D%97\/","datePublished": "2020-07-01T09:11:25+08:00","dateModified": "2020-07-01T09:11:25+08:00","publisher": {
            "@type": "Organization",
            "name": "辛载阳"},"author": {
                "@type": "Person",
                "name": "辛载阳"
            },"description": ""
    }
    </script></head>
    <body header-desktop="fixed" header-mobile="auto"><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="Pour l&#39;honneur de l&#39;esprit humain.">Pour l&#39;honneur de l&#39;esprit humain</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/categories/"> 分类 </a><a class="menu-item" href="/publication" title="Publication"> 论文 </a><a class="menu-item" href="/projects" title="Projects"> 项目 </a><a class="menu-item" href="https://www.linkedin.com/in/feiyuxiao/" title="CVpdf" rel="noopener noreffer" target="_blank"> 关于 </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="Pour l&#39;honneur de l&#39;esprit humain.">Pour l&#39;honneur de l&#39;esprit humain</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/categories/" title="">分类</a><a class="menu-item" href="/publication" title="Publication">论文</a><a class="menu-item" href="/projects" title="Projects">项目</a><a class="menu-item" href="https://www.linkedin.com/in/feiyuxiao/" title="CVpdf" rel="noopener noreffer" target="_blank">关于</a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">Hugo博客写作指南</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel=" author" class="author"><i class="fas fa-user-circle fa-fw"></i>辛载阳</a></span>&nbsp;<span class="post-category">收录于 <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA/"><i class="far fa-folder fa-fw"></i>计算机</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2020-07-01">2020-07-01</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 358 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 1 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents"></nav></div>
            </div><div class="content" id="content"><p>自从博客从 Hexo 迁移到 Hugo 之后，购买了个人域名 <a href="https://xiaofy.top/" target="_blank" rel="noopener noreffer">xiaofy.top</a>  ，基本上也是经常更新，也逐渐形成了个人博客更新写作的整个工具链。</p>
<p>如果是本地只写作博客的话，我使用 Typora 这样一个跨平台软件进行写作，每次通过新建文章和预览</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-go" data-lang="go"><span class="nx">hugo</span> <span class="nx">new</span> <span class="nx">posts</span><span class="o">/</span><span class="nx">post_name</span><span class="p">.</span><span class="nx">md</span>
<span class="nx">hugo</span> <span class="nx">server</span> 
</code></pre></div><p>为了自动化部署写了一个脚本：</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="cp">#!/bin/sh
</span><span class="cp"></span>
<span class="c1"># If a command fails then the deploy stops</span>
<span class="nb">set</span> -e

<span class="nb">printf</span> <span class="s2">&#34;\033[0;32mDeploying updates to GitHub...\033[0m\n&#34;</span>

<span class="c1"># Build the project.</span>
hugo <span class="c1"># if using a theme, replace with `hugo -t &lt;YOURTHEME&gt;`</span>

<span class="c1"># Go To Public folder</span>
<span class="nb">cd</span> public

<span class="c1"># Add changes to git.</span>
git add .

<span class="c1"># Commit changes.</span>
<span class="nv">msg</span><span class="o">=</span><span class="s2">&#34;rebuilding site </span><span class="k">$(</span>date<span class="k">)</span><span class="s2">&#34;</span>
<span class="k">if</span> <span class="o">[</span> -n <span class="s2">&#34;</span><span class="nv">$*</span><span class="s2">&#34;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
	<span class="nv">msg</span><span class="o">=</span><span class="s2">&#34;</span><span class="nv">$*</span><span class="s2">&#34;</span>
<span class="k">fi</span>
git commit -m <span class="s2">&#34;</span><span class="nv">$msg</span><span class="s2">&#34;</span>

<span class="c1"># Push source and build repos.</span>
git push origin master
</code></pre></div><p>比较有用的是使用 PicGo 和 码云 搭建了一个免费的个人图床，访问速度很快，教程可以参考这篇：<a href="https://www.cnblogs.com/geq2020/p/12506466.html" target="_blank" rel="noopener noreffer">PicGo+Gitee搭建个人图床</a></p>
<p>此外，推荐一个平台 <a href="https://www.mdnice.com/" target="_blank" rel="noopener noreffer">让微信排版变Nice</a>，当我需要 Blog ，微信公众号一起更新的时候我就会使用这个平台，支持一键复制到微信公众号和知乎，非常非常方便。排版出来的公众号文章也是非常好看，这是我最近排版的一篇文章 <a href="https://mp.weixin.qq.com/s/V0LSG0LC7F8bqZOEetxZAw" target="_blank" rel="noopener noreffer">谈谈KMT和九二共识</a>。</p>
</div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2020-07-01</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/hugo/">hugo</a>,&nbsp;<a href="/tags/markdown/">markdown</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/posts/%E8%B0%88%E8%B0%88kmt%E5%92%8C%E4%B9%9D%E4%BA%8C%E5%85%B1%E8%AF%86/" class="prev" rel="prev" title="谈谈KMT和“九二共识&#34;"><i class="fas fa-angle-left fa-fw"></i>谈谈KMT和“九二共识&#34;</a>
            <a href="/posts/%E7%A7%8B%E6%8B%9B%E6%80%BB%E7%BB%93/" class="next" rel="next" title="秋招总结">秋招总结<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.87.0">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2016 - 2021</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank">辛载阳</a></span>&nbsp;|&nbsp;<span class="license"><a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a></span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><link rel="stylesheet" href="/lib/katex/katex.min.css"><link rel="stylesheet" href="/lib/katex/copy-tex.min.css"><script type="text/javascript" src="/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/algoliasearch/algoliasearch-lite.umd.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="/lib/katex/katex.min.js"></script><script type="text/javascript" src="/lib/katex/auto-render.min.js"></script><script type="text/javascript" src="/lib/katex/copy-tex.min.js"></script><script type="text/javascript" src="/lib/katex/mhchem.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":10},"comment":{},"math":{"delimiters":[{"display":true,"left":"$$","right":"$$"},{"display":true,"left":"\\[","right":"\\]"},{"display":false,"left":"$","right":"$"},{"display":false,"left":"\\(","right":"\\)"}],"strict":false},"search":{"algoliaAppID":"MAYVVVUE0B","algoliaIndex":"feiyuxiaoThu","algoliaSearchKey":"eb3e163b921c3d50a89091f127fe6d14","highlightTag":"em","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":50,"type":"algolia"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
